/**
 * Created by lihao on 2017/6/28.
 */
const keystone = require('keystone');
const Promise = require('bluebird');
const _ = require('lodash');
const Post = keystone.list('User');
exports = module.exports = function (req, res) {
    let reqQuery = _.omit(_.assign(req.query, req.body, req.param), []);
    let omitFueld = ['password', 'isAdmin', '__v'];
    let optionalExpression = _.transform(omitFueld, function (r, val) {
        r[val] = 0;
    }, {});
    if (reqQuery.password != reqQuery.password_confirm) {
        return res.json({code: 0, message: '两次密码输入不一至'});
    } else {

    }
    var item = new Post.model(reqQuery);
    item.save(function (err) {
        if (err) return res.json({code: 0, message: '新建用户失败。'});
        return res.json({code: 1, message: '新建用户成功', data: _.omit(item, omitFueld)});
    });

};
